// logs.js
const {get_singerList} = require('../../utils/ajax.js')
// import { getSingerList } from '../../utils/ajax'

Page({
  data: {
    logs: [],
    typeList1: ["热门", ..."ABCDEFGHIGKLMNOPQRSTUVWXYZ".split("")],
    index1: 0,
    page: 1,
    index2: 0,
    typeList2: ["全部", "华语男", "华语女", "华语组合", "日韩男", "日韩女", "日韩组合", "欧美男", "欧美女", "欧美组合", "其他"],
    geshou: []
  },
  changeType1(e) {
    this.setData({
      index1: e.currentTarget.dataset.index,
      singerList: [],
      page: 1
    }, () => {
      this.getSinger(this.data.index1)
    })
    console.log(this.data.index1);
  },
  changeType2(e) {
    this.setData({
      index2: e.currentTarget.dataset.index,
      singerList: [],
      page: 1
    }, () => {
      this.getSingerList()
    })
  },
  // 歌手轮播图
  onLoad() {
    this.getSinger(1)
    
  },
  getSinger(singerId){
    wx.request({
      url: 'http://127.0.0.1:8080/artist/artistInfo?category='+singerId+'&pn=1&rn=100',
      success: res => {
        console.log(666, res.data.data.artistList);
        // let arr = JSON.stringify(res.data.data.artistList)
        this.setData({
          geshou: res.data.data.artistList
        })
      }
    })
  },
  getSingerList() {
    let option = {
      category: this.data.index2,
      pn: this.data.page,
      rn: 8
    }
    this.data.index1 && (option.prefix = this.data.typeList1[this.data.index1])
    get_singerList(option).then(res => {
      this.setData({
        singerList:[...this.data.singerList,...res.data.artistList]
      })
    })
  }


})